import { request } from '../request';

/**
 * Login
 *
 * @param userName User name
 * @param password Password
 */
export function fetchLogin(userName: string, password: string) {
  // return request<Api.Auth.LoginToken>({
  //   url: '/auth/login',
  //   method: 'post',
  //   data: {
  //     username: userName,
  //     password
  //   }
  // });
  return {
      "id": 1,
      "username": "admin",
      "role": 2,
      "namespaceIds": [
          {
              "id": 1,
              "name": "Default",
              "uniqueId": "764d604ec6fc45f68cd92514c40e9e1a"
          }
      ],
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjAyMzQ5MDIsImF1ZCI6IntcImlkXCI6MSxcInVzZXJuYW1lXCI6XCJhZG1pblwiLFwicm9sZVwiOjIsXCJjcmVhdGVEdFwiOlwiMjAyNC0wNy0wNCAxMDowMDo1NlwiLFwidXBkYXRlRHRcIjpcIjIwMjQtMDctMDQgMTA6MDA6NTZcIn0ifQ._ExrNIKh3GQicmtLNYW_l6kbrEC7ao1yEc9E9uR1Ct0",
      "createDt": "2024-07-04 10:00:56",
      "updateDt": "2024-07-04 10:00:56"
  }
}

/** Get user info */
export function fetchGetUserInfo() {
  // return request<Api.Auth.UserInfo>({ url: '/user/info' });
    return {
            "id": 1,
            "username": "admin",
            "role": 2,
            "namespaceIds": [
            {
                "id": 1,
                "name": "Default",
                "uniqueId": "764d604ec6fc45f68cd92514c40e9e1a"
            }
        ]
    }
}

/**
 * Refresh token
 *
 * @param refreshToken Refresh token
 */
export function fetchRefreshToken(refreshToken: string) {
  return request<Api.Auth.LoginToken>({
    url: '/auth/refreshToken',
    method: 'post',
    data: {
      refreshToken
    }
  });
}

/**
 * return custom backend error
 *
 * @param code error code
 * @param msg error message
 */
export function fetchCustomBackendError(code: string, msg: string) {
  return request({ url: '/auth/error', params: { code, msg } });
}
